

//TODO a(39)
function a39(module, exports, a) {
    var i = a(23), s = a(3), r = a(4), n = a(21), o = a(2), l = function () {
    };
    s.extend(l, i);
    var d = {
        init: function () {
            this.playerData = this.manager.playerData, this.isServerTime = !1, this.isDomain = 0, this.serverTime = null, this.isRetryCookie = !1, this.requestType = "new", this.manager.listener.on(n.PLAY_STATE, this.onPlayStateChange, this)
        }, onPlayStateChange: function (e, t) {
            "init" == t && (this.isServerTime = !1, this.serverTime = null, this.isRetryCookie = !1, this.isDomain = 0)
        }, getMms: function () {
            this.getRequest()
        }, getRequest: function () {
            var e;
            if (this.isServerTime) {
                if (!this.serverTime)throw"mms api need server time";
                e = this.serverTime
            } else e = s.now() / 1e3;
            switch (this.isDomain) {
                case 0:
                    timeOut = 5e3;
                    break;
                case 1:
                    timeOut = 8e3;
                    break;
                case 2:
                default:
                    timeOut = 1e4
            }
            var domainHost, playJsonUrl = n.PROTOCAL + n.HOST_NAME.PLAYER_PC_LETV_COM + "/mms/out/video/playJson.json", ttkey = r.getMmsKey(e);
            if (this.playerData.videoType = !this.playerData.config.supportP2P && "" != o.supportM3U8 && "1" != o.supportM3U8 || o.forceMp4 ? "no" : "ios", parent === window)try {
                domainHost = location.host
            } catch (l) {
                domainHost = "." + document.domain
            }
            var d = {1: "350", 2: "1000", 3: "1300", 4: "720p"}, playJsonData = {
                platid: 3,
                splatid: this.playerData.config.splatId,
                tss: this.playerData.videoType,
                id: this.playerData.vinfo.vid,
                detect: this.playerData.flashVar.mmDetect || "1",
                dvtype: d[this.playerData.config.defi] || "",
                accessyx: 1,
                domain: domainHost,
                tkey: ttkey,
                devid: this.manager.pingback.getLC(),
                source: "1001",
                lang: this.playerData.flashVar.lan,
                region: this.manager.listener.get(n.REGION),
                isHttps: 1 == this.playerData.flashVar.isHttps ? 1 : 0
            };
            this.manager.log.pushLog("mmsGet: ===_antiLeech===" + s.getCookie("_antiLeech")), this.jsonp = s.getJSON({
                url: playJsonUrl,
                data: playJsonData,
                log: this.manager.log,
                maxCount: 1,
                timeout: timeOut,
                success: s.bind(this.onSuccess, this),
                fail: s.bind(this.onFail, this)
            })
        }, getRequest2: function () {
            var e;
            if (this.isServerTime) {
                if (!this.serverTime)throw"mms api need server time";
                e = this.serverTime
            } else e = s.now() / 1e3;
            var t, a = 0;
            switch (this.isDomain) {
                case 0:
                    t = n.HOST_NAME.API_LETV_COM, a = 5e3;
                    break;
                case 1:
                    t = n.HOST_NAME.API_WWW_LETV_COM, a = 8e3;
                    break;
                case 2:
                default:
                    t = "MPlayer" == this.playerData.pname ? n.HOST_NAME.D_APi_M_LETV_COM : "117.121.54.104", a = 1e4
            }
            var domainHost, playJsonH5Url = n.PROTOCAL + t + "/mms/out/video/playJsonH5", h5tkey = r.getMmsKey(e);
            if (this.playerData.videoType = !this.playerData.config.supportP2P && "" != o.supportM3U8 && "1" != o.supportM3U8 || o.forceMp4 ? "no" : "ios", parent === window)try {
                domainHost = location.host
            } catch (h) {
                domainHost = "." + document.domain
            }
            var c = {1: "350", 2: "1000", 3: "1300", 4: "720p"}, p = {
                platid: 3,
                splatid: "MPlayer" == this.playerData.pname ? "301" : "304",
                tss: this.playerData.videoType,
                id: this.playerData.vinfo.vid,
                detect: this.playerData.flashVar.mmDetect || "1",
                dvtype: c[this.playerData.config.defi] || "",
                accessyx: 1,
                domain: domainHost,
                tkey: h5tkey,
                devid: this.manager.pingback.getLC()
            };
            this.manager.log.pushLog("mmsGet: ===_antiLeech===" + s.getCookie("_antiLeech")), this.jsonp = s.getJSON({
                url: playJsonH5Url,
                data: p,
                log: this.manager.log,
                maxCount: 1,
                timeout: a,
                success: s.bind(this.onSuccess, this),
                fail: s.bind(this.onFail, this)
            })
        }, onSuccess: function (data) {
            if (this.jsonp = null, this.manager.log.pushLog("mms Suc: " + s.JSONTOStr(data)), data.code && 1 != data.code)return void this.sendError(n.ERROR_CODE.ERROR);
            if (data = data.msgs || data, data.drmFlag)return void this.sendError(n.ERROR_CODE.DRM_BAN);
            if (1003 == data.statuscode) data.playstatus && data.playstatus.stime ? this.isServerTime ? this.sendError(n.ERROR_CODE.AUTH_TIME_SERVER_ERROR) : (this.serverTime = data.playstatus.stime, this.isServerTime = !0, this.getRequest()) : this.sendError(n.ERROR_CODE.AUTH_ARGS_ERR); else if (1002 == data.statuscode) this.sendError(n.ERROR_CODE.AUTH_ARGS_ERR); else if (1 == data.playstatus.status) {
                if (data.checkstatus && 1e4 != data.checkstatus) {
                    if (10005 == data.checkstatus && !this.isRetryCookie)return this.isRetryCookie = !0, this.manager.log.pushLog("mms cookie fail,retry"), void this.retryCookie();
                    this.manager.pingback.sendError(n.ERROR_CODE.AUTH_COOKIE_CHECK_ERR), 1 == Math.floor(400 * Math.random() + 1) && this.manager.log.send({
                        errno: n.ERROR_CODE.AUTH_COOKIE_CHECK_ERR,
                        forceSend: !0
                    })
                }
                this.isRetryCookie = !1, this.parseMovieVO(data)
            } else switch (data.playstatus.flag) {
                case 0:
                    this.sendError(n.ERROR_CODE.OFFLINE);
                    break;
                case 2:
                case 3:
                case 5:
                    this.sendError(n.ERROR_CODE.COPY_RIGHT_BAN);
                    break;
                case 4:
                case 6:
                    this.sendError(n.ERROR_CODE.ERROR);
                    break;
                case 1:
                    this.sendError(n.ERROR_CODE.AREA_BAN)
            }
        }, onFail: function (e) {
            this.jsonp = null, this.manager.log.pushLog("mmsFail isDomain: " + this.isDomain),
                ++this.isDomain <= 2 ? "new" == this.requestType ? this.getRequest() : this.getRequest2() : "new" == this.requestType && "cn" == this.manager.listener.get(n.REGION) && 0 == this.playerData.flashVar.isHttps ? (this.manager.pingback.sendProxyError(800, e.url), this.requestType = "old", this.isDomain = 0, this.getRequest2()) : this.sendError(n.ERROR_CODE.AUTH_TIMEOUT)
        }, retryCookie: function () {
            this.jsonp = s.getJSON({
                url: n.PROTOCAL + n.HOST_NAME.D_APi_M_LETV_COM + "/api/flushCookie",
                data: {vid: this.playerData.vinfo.vid},
                log: this.manager.log,
                success: s.bind(function () {
                    this.getRequest()
                }, this),
                fail: s.bind(function () {
                    this.sendError(n.ERROR_CODE.AUTH_COOKIE_RETRY_ERROR)
                }, this)
            })
        }, parseMovieVO: function (e) {
            var t = e.playurl, a = {
                cid: t.cid,
                pid: t.pid,
                vid: t.vid,
                title: t.title,
                nextvid: t.nextvid,
                gdur: parseInt(t.duration),
                poster: s.merge({defaultPic: t.imgprefix + "/thumb/2_"}, t.picAll),
                ispay: 0 != e.trylook,
                payTrylookTime: Math.floor(Math.min(540, "number" == typeof e.trylookTime ? e.trylookTime : 360) / 60),
                firstlook: "0" != e.firstlook,
                cutoff_p: e.cutoff_p,
                cutoff_t: e.cutoff_t,
                isAlbumPay: e.isAlbumPay
            };
            e.danmu && this.manager.evt.trigger("vjs_danmuSucc");
            var i, r, o, l = {};
            for (var d in t.dispatch)if (!t.dispatch[d][2] && (o = t.dispatch[d][0], r = o.match(/(\?|&)vtype=([^&]+)(&|$)/)[2] || "", i = null, 182 == r || 21 == r && !l[1] ? i = 1 : 183 == r || 13 == r && !l[2] ? i = 2 : 22 == r && (i = 3), i)) {
                l[i] = {urls: [], vtype: r, storePath: t.dispatch[d][1]};
                for (var h = 0, c = t.domain.length; h < c; h++)l[i].urls.push(t.domain[h] + o)
            }
            if (s.isEmptyObj(l))return void this.sendError(n.ERROR_CODE.AUTH_DATA_EMPTY);
            var p = {
                vinfo: a,
                movieVO: l,
                userInfo: this.manager.user.formatUserInfo(e.userinfo),
                curVType: e.curVType
            };
            this.playerData.validateInfo = e.yuanxian || {}, this.manager.log.pushLog("vjs_mmsSucc: " + s.JSONTOStr(p)), this.manager.evt.trigger("vjs_mmsSucc", p)
        }
    };
    s.merge(l.prototype, d), module.exports = l
}

